package com.chushouya.controller.open;

import com.chushouya.common.annotations.AuthSkip;
import com.chushouya.common.constant.ServiceType;
import com.chushouya.order.dto.api.dangdang.DangDangOrderPushDTO;
import com.chushouya.order.service.api.DangDangApiService;
import com.general.framework.core.schema.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 当当订单推送控制器
 *
 * @author chushouya
 * @date 2025-10-31
 */
@Slf4j
@RestController
@RequestMapping(ServiceType.OPENAPI + "/dangdang")
@Api(tags = ServiceType.OPENAPI + "当当订单推送接口")
public class DangDangPushController {

    @Resource
    private DangDangApiService dangDangApiService;

    /**
     * 当当订单推送接口
     */
    @PostMapping("/orderPush")
    @AuthSkip
    @ApiOperation("当当订单推送")
    public Response<String> orderPush(@RequestBody DangDangOrderPushDTO orderPushDTO) {
        try {
            log.info("收到当当订单推送通知: {}", orderPushDTO);
            
            // 调用服务处理订单推送
            dangDangApiService.handleOrderPush(orderPushDTO);
            
            return Response.success("OK");
        } catch (Exception e) {
            log.error("处理当当订单推送失败", e);
            return Response.success("OK");
        }
    }
}
